package com.shop.zkmall.app.controller.a;

import com.shop.zkmall.app.domain.req.*;
import com.shop.zkmall.app.page.banner.ShopBanner;
import com.shop.zkmall.app.service.a.ICereBuyerLiveRoomService;
import com.shop.zkmall.commons.result.R;
import com.shop.zkmall.commons.result.Result;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("live")
@RequiredArgsConstructor
@Tag(name = "直播模块", description = "直播模块")
public class LiveController {

    private final ICereBuyerLiveRoomService iCereBuyerLiveRoomService;



    /**
     * 保存直播前设置
     */
    @PostMapping("/saveLiveSetting")
    @Operation(summary = "主播-保存直播前设置")
    public R<?> saveLiveSetting(@RequestBody CereBuyerLiveRoomReq cereBuyerLiveRoomReq) {
        return iCereBuyerLiveRoomService.saveLiveSetting(cereBuyerLiveRoomReq);
    }


    /**
     * 开始直播
     */
    @PostMapping("/startLive")
    @Operation(summary = "主播-开始直播")
    public R<?> startLive(@RequestBody StartLiveReq startLiveReq) {
        return iCereBuyerLiveRoomService.startLive(startLiveReq);
    }


    @ApiOperation("观众-获取直播间播放地址")
    @GetMapping("/play/{roomId}")
    public R<?> getPlayUrl(@PathVariable Long roomId) {
        return iCereBuyerLiveRoomService.getPlayUrl(roomId);
    }


    /**
     * 用户加入直播间
     */
    @PostMapping("/joinLiveRoom")
    @Operation(summary = "观众-加入直播间")
    public R<?> joinLiveRoom(@RequestBody JoinLiveRoomReq joinLiveRoomReq) {
        return iCereBuyerLiveRoomService.joinLiveRoom(joinLiveRoomReq);
    }



    @ApiOperation("主播-讲解商品")
    @PostMapping("explainProduct")
    public R<?> explainProduct(@RequestBody ExplainProductReq explainProductReq) {
        return iCereBuyerLiveRoomService.explainProduct(explainProductReq);
    }


    @ApiOperation("观众-直播间竞拍出价")
    @PostMapping("liveAuctionSendPrice")
    public R<?> liveAuctionSendPrice(@RequestBody LiveAuctionSendPriceReq liveAuctionSendPriceReq) {
        return iCereBuyerLiveRoomService.liveAuctionSendPrice(liveAuctionSendPriceReq);
    }

    @ApiOperation("观众-直播间抢购")
    @PostMapping("snapProduct")
    public R<?> snapProduct(@RequestBody SnapProductReq snapProductReq) {
        return iCereBuyerLiveRoomService.snapProduct(snapProductReq);
    }



    @ApiOperation("观众-直播间赠送礼物")
    @PostMapping("sendGift")
    public R<?> sendGift(@RequestBody SendGiftReq sendGiftReq) {
        return iCereBuyerLiveRoomService.sendGift(sendGiftReq);
    }



    /**
     * 搜索直播间商品
     */
    @PostMapping("/searchLiveProduct")
    @Operation(summary = "搜索直播间商品")
    public R<?> searchLiveProduct(@Param("keyWord") String keyWord) {
        return iCereBuyerLiveRoomService.searchLiveProduct(keyWord);
    }
}
